﻿#ifndef __MATERIAL_MANAGER_H__
#define __MATERIAL_MANAGER_H__

#pragma once

#include "Material.h"

namespace Nezha
{

	/**
	@REMAKRS
		Íâ²¿Ó¦Ê¹ÓÃÖÇÄÜÖ¸Õë±£´æ´´½¨µÄ¶ÔÏó£¬µ±Ã»ÓÐÆäËû¶ÔÏóÒýÓÃ¸Ã¶ÔÏóÊ±£¬¹ÜÀíÆ÷½«É¾³ý¸Ã¶ÔÏó¡£
	*/
	class NEZHA_ENGINE_ENTRY MaterialManager : public RefCountedResManager
	{
	public:
		virtual ~MaterialManager();

		virtual MaterialPtr findMaterial(const _string& name);

		virtual MaterialPtr createMaterial(const _string& scriptName);

		/** 创建默认shader对应的材质，创建不会重复。 */
		virtual MaterialPtr createDefaultMaterial(DefaultShaderType dst = DST_VERTEX_COLOR);

		virtual MaterialPtr cloneMaterial(const MaterialPtr& matTemplate);

		virtual void removeAll();

	protected:
		virtual void _garbageDispose();

		typedef PMap<_string, MaterialPtr, _NzStrLess> MaterialNameMap;

		MaterialPtr mDefaultMats[DST_NUM];

		MaterialNameMap mMaterialMap;
	};

}//end namespace Nezha

#endif //end __MATERIAL_MANAGER_H__